<%--
  Created by IntelliJ IDEA.
  User: ming
  Date: 2021/11/18
  Time: 11:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>西游记</title>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<%--点击事件之后返回的文本到div中--%>
<div id="msg"></div>
<hr>
<button id="btn1">大徒弟get</button>
<button id="btn2">二徒弟post</button>
<button id="btn3">找徒弟get2</button>
<button id="btn4">徒弟put</button>
<button id="btn5">打妖怪del</button>
<%--其他端口连接<a href="http://localhost:8081/shop/getPro">aaa</a>--%>
<script>
    $(function () {
        $("#btn1").click(function () {
            $.ajax({
                url: "/user/t1",
                //请求方式
                type: "get",
                success: function (data) {
                    $("#msg").text(data);
                }
            })
        })
        $("#btn2").click(function () {
            $.ajax({
                url: "/user/t1",
                type: "post",
                success: function (data) {
                    $("#msg").text(data);
                }
            })
        })
        $("#btn3").click(function () {
            var name = "就这";
            $.ajax({
                url: "/user/t1" + name,
                type: "get",
                //dataType值如果为'text'，结果弹出框直接显示后台返回的json字符串。
                dataType: "text",
                success: function (data) {
                    $("#msg").text(data);
                }
            })
        })
        $("#btn4").click(function () {
            var user = {uno:22,uname:"二郎神",usex:"男"};
            $.ajax({
                url: "/user/t1",
                type: "put",
                dataType: "text",
                data:JSON.stringify(user),
                contentType:"application/json",
                success: function (data) {
                    $("#msg").text(data);
                }
            })
        })
        $("#btn5").click(function () {
            var num=66;
            $.ajax({
                url: "/user/t1"+num,
                type: "delete",
                dataType: "text",
                data:JSON.stringify(user),
                contentType:"application/json",
                success: function (data) {
                    $("#msg").text(data);
                }
            })
        })
    })


</script>


</body>
</html>
